package com.free.mini.core.serve.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import com.free.mini.common.base.ResultData;
import com.free.mini.core.serve.exception.CoreServiceException;

/**
 * @author dongsufeng
 * @version 4.0
 * @date 2023/8/19 14:20
 */
@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    @ExceptionHandler(CoreServiceException.class)
    public ResultData handleException(CoreServiceException e) {
        log.error("coreServiceException",e);
        return ResultData.error(e.getCode() , e.getMessage());
    }
    @ExceptionHandler(Exception.class)
    public ResultData handleException(Exception e) {
        log.error("Exception",e);
        return ResultData.error();
    }
}
